<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /><!-- 控制浏览器文件模式为IE8 -->
<title>角色新增</title>

<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="js/artDialog/skins/default.css" rel="stylesheet" type="text/css" />
<link href="css/sele.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/artDialog/artDialog.js?skin=blue"></script>
<script src="js/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/elegant/om-all.css" />
<script> 
(function (config) {
    config['lock'] = true;
    config['fixed'] = true;
    config['okVal'] = 'Ok';
    config['cancelVal'] = 'Cancel';
})(art.dialog.defaults);
</script>
<script language="javascript">
	var j = jQuery.noConflict();
	j.ajaxSetup({
		cache:false,
		async: false
	});
</script>
<script>
	function submitForm() {
		var name=document.getElementById("roleName").value;
		var code=document.getElementById("roleCode").value;
		var flag=true;
		if(name==null || name=="")
		{
			document.getElementById("roleName").focus();
			art.dialog.tips('角色名称不能为空！', 1.5);
			flag=false;
			return;	
		}
		if(code==null || code=="")
		{
			document.getElementById("roleCode").focus();
			art.dialog.tips('角色代码不能为空！', 1.5);
			flag=false;
			return;
		}
		if(flag)
		{
			document.forms[0].submit();
		}
	}
	function checkCode(code)
	{
		if(code!="ROLE_ADMIN" && code!="ROLE_USER")
		{
			art.dialog.tips('角色代码只能为ROLE_ADMIN和ROLE_USER！', 1.5);
		}
	}
	function selectAll(obj)
	{
		var length=obj.id.length;
		var checkbx = j(":checkbox");
		if(obj.checked)
		{
			//全选
			for(var i=0;i<checkbx.length;i++)
			{
				if(checkbx[i].id.length>length)
				{
					var str=checkbx[i].id.substring(0,length);
					if(str==obj.id)
					{
						checkbx[i].checked=true;
					}
				}
			}
		}
		else{
			//全取消
			for(var i=0;i<checkbx.length;i++)
			{
			if(checkbx[i].id.length>length)
				{
					var str=checkbx[i].id.substring(0,length);
					if(str==obj.id)
					{
						checkbx[i].checked=false;
					}
				}
			}
		}
	}
</script>
</head>
<body>

	<div class="place">
	    <span>位置：</span>
	    <ul class="placeul">
	    <li>首页</li>
		<li>系统管理</li>
	    <li><a href="#" onclick="javascript:window.location.href='./adminRole.do?action=list'"> 角色管理</a></li>
		<li>新增角色</li>
	    </ul>
    </div>
    <div class="rightinfo">
		<form id="form1" action="./adminRole.do?action=addRole" method="post">

			<ul class="seachform">
				<li>
					<label>角色名称：</label>
					<input id="roleName" type="text" name="roleName" size="10" style="width:100px;height:32px;" class="scinput" autocomplete="off"/>
				</li>
				<li>
					<label>角色代码：</label>
				    <select id="roleCode" name="roleCode" class="form-control" style="width:230px;">
				    	<option value="ROLE_ADMIN">超级管理员</option>
				    	<option value="ROLE_WF_ADMIN">流程管理員</option>
			           	<option value="ROLE_KPI_BU_USER">異常管理員</option>
			           	<option value="ROLE_KPI_BU_AUDITOR">異常管理審核主管</option>
			           	<option value="ROLE_SAFETY_PORTAL">門戶網站管理員</option>
			           	<option value="ROLE_RES_ADMIN">安防資源管理員</option>
			           	<option value="ROLE_NORMAL_SIGN_USER">普通簽核人員</option>
			           	
			           	<option value="ROLE_WF_A1.1_APPLY_DEPT_APPLYER">a1.1需求單位表單申請人</option>
			           	<option value="ROLE_WF_A1.1_APPLY_DEPT_NDA">a1.1需求單位NDA專員</option>
						<option value="ROLE_WF_A1.1_APPLY_DEPT_AUDITOR">a1.1需求單位審核人</option>
						<option value="ROLE_WF_A1.1_FACTORY_PRODUCT_SAFETY_CONFIRMER">a1.1廠區-產品安全處確認主管</option>
						<option value="ROLE_WF_A1.1_FACTORY_MARSTER">a1.1廠區核准權限主管</option>
						
						<option value="ROLE_WF_A1.2_APPLY_DEPT_APPLYER">a1.2需求單位表單申請人</option>
						<option value="ROLE_WF_A1.2_APPLY_DEPT_NDA">a1.2需求單位NDA專員</option>
						<option value="ROLE_WF_A1.2_APPLY_DEPT_AUDITOR">a1.2需求單位審核人</option>
						<option value="ROLE_WF_A1.2_FACTORY_APPROVED_MARSTER">a1.2廠區核准權限主管</option>
						
						<option value="ROLE_WF_A1_FACTORY_SMART_MANAGEMENT_DEPT_NDA">a1廠區-智權管理部-NDA專員</option>
						
						<option value="ROLE_WF_A3_APPLY_DEPT_AUDITOR">a3需求單位審核人</option>
						<option	value="ROLE_WF_A3_APPLY_DEPT_FACTORY_DEPT_APPROVED_MARSTER">a3需求單位廠部級主管核準</option>
						<option value="ROLE_WF_A3_PRODUCT_SAFETY_SENDER">a3產品安全處派件人</option>
						<option value="ROLE_WF_A3_PRODUCT_SAFETY_ASSESSOR">a3產品安全處規劃評估人員</option>
						<option value="ROLE_WF_A3_PRODUCT_SAFETY_CONFIRMER">a3產品安全處確認主管</option>
						<option value="ROLE_WF_A3_APPLY_DEPT_APPLYER">a3需求單位表單申請人</option>
						
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_AUDITOR1">a4產品安全處一級審核主管</option>
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_AUDITOR2">a4產品安全處二級審核主管</option>
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_AUDITOR3">a4產品安全處三級審核主管</option>
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_APPROVED_MARSTER">a4產品安全處核准主管</option>
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_ASSESSOR">a4產品安全處評估作業人員</option>
						<option value="ROLE_WF_A4_APPLY_DEPT_AUDITOR">a4需求單位審核人</option>
						<option	value="ROLE_WF_A4_APPLY_DEPT_FACTORY_DEPT_APPROVED_MARSTER">a4需求單位廠部級主管核準</option>
						<option value="ROLE_WF_A4_APPLY_DEPT_APPLYER">a4需求單位表單申請人</option>
						<option value="ROLE_WF_A4_FACTORY_OPERATION_CONTROL1">a4廠區-經管一級簽核人</option>
						<option value="ROLE_WF_A4_FACTORY_OPERATION_CONTROL2">a4廠區-經管二級簽核人</option>
						<option value="ROLE_WF_A4_FACTORY_OPERATION_CONTROL3">a4廠區-經管三級簽核人</option>
						
						<option value="ROLE_WF_A5_APPLY_DEPT_APPLYER">a5需求單位表單申請人</option>
						<option value="ROLE_WF_A5_APPLY_DEPT_SAFETY_MASKER">a5需求單位安全主管</option>
						<option value="ROLE_WF_A5_APPLY_DEPT_AUDITOR">a5需求單位審核人</option>
						<option	value="ROLE_WF_A5_APPLY_DEPT_FACTORY_DEPT_APPROVED_MARSTER">a5需求單位廠部級核準主管</option>
						<option value="ROLE_WF_A5_PRODUCT_SAFETY_AUDITOR1">a5產品安全處一級審核主管</option>
						<option value="ROLE_WF_A5_PRODUCT_SAFETY_AUDITOR2">a5產品安全處二級審核主管</option>
						<option value="ROLE_WF_A5_PRODUCT_SAFETY_AUDITOR3">a5產品安全處三級審核主管</option>
						<option value="ROLE_WF_A5_PRODUCT_SAFETY_APPROVED_MARSTER">a5產品安全處核准主管</option>
						<option value="ROLE_WF_A5_MONITOR_INQUIRY_TASK_PERSON">a5監控調閱作業人員</option>
						
						<option value="ROLE_WF_A6_PRODUCT_SAFETY_CONFIRMER">a6產品安全處確認主管</option>
						<option value="ROLE_WF_A6_APPLY_DEPT_APPLYER">a6需求單位表單申請人</option>
						<option value="ROLE_WF_A6_APPLY_DEPT_AUDITOR">a6需求單位審核人</option>
						<option	value="ROLE_WF_A6_APPLY_DEPT_FACTORY_DEPT_APPROVED_MARSTER">a6需求單位廠部級主管核準</option>
						<option value="ROLE_WF_A6_APPLY_DEPT_MANUFACTURE_MARSTER">a6需求單位製造處處級核準主管</option>
						<option value="ROLE_WF_A6_PRODUCT_SAFETY_UPLOSDER">a6產品安全處表單上傳員</option>
				</select>
				</li>
				<li>
					<label>角色描述：</label>
					<input id="roleDesc" type="text" name="description" size="10" style="width:265px;height:32px;" class="scinput" autocomplete="off"/>
				</li>
			</ul>
			<table class="tablelist">
				<thead>
					<tr>
						<td>功能</td>
            			<td>说明</td>
            			<td>权限</td>
					</tr>
				</thead>
				<tbody>
				<c:forEach var="list" items="${firstMenuList}">
					<tr style="background: #D8E5F2;">
						<td width="25%" ><div style="float: left;">${list.function.functionName}</div></td>
						<td>${list.function.description }</td>
						<td><input type="checkbox" style="width:20px;" name="functionId" onclick="selectAll(this);" value="${list.function.functionId }" id="${list.function.functionCode }"/></td>
			        </tr>
					<c:if test="${list.secondMenuSize>0}">
		          		<c:forEach var="secondList" items="${list.secondMenuList}">
		          			<tr style="background: #EDF6FA;">
		          				<td width="20%"><div style="padding-left:40px;">${secondList.function.functionName}</div></td>
		          				<td>${secondList.function.description }</td>
		          				<td><input type="checkbox" style="width:20px;" id="${secondList.function.functionCode }"  name="functionId" <c:if test="${secondList.thirdMenuSize!=0}">onclick="selectAll(this);"</c:if> value="${ secondList.function.functionId}"/></td>
		          			</tr>
		          			<c:if test="${secondList.thirdMenuSize>0}">
		          				<c:forEach var="thirdList" items="${secondList.thirdMenuList}">
		          					<tr>
		          						<td width="25%"><div style="padding-left:80px;">${thirdList.function.functionName }</div></td>
		          						<td>${thirdList.function.description }</td>
		          						<td><input type="checkbox" style="width:20px;" name="functionId" id="${thirdList.function.functionCode }" value="${thirdList.function.functionId }"/></td>
		          					</tr>
		          				</c:forEach>
		          			</c:if>
		          		</c:forEach>
		          	</c:if>
		        </c:forEach>
				</tbody>
			</table>
          	<ul class="forminfo" style="margin-top:30px;">
			    <li>
					<label>&nbsp;</label>
					<input name="" type="button" id="save" onclick="submitForm();" class="btn" value="确定创建"/> 
					<input style="margin-left:100px;" onclick="javascript:document.location.href = './adminRole.do?action=list';" type="button" class="cancel" value="取消创建" />
				</li>
		    </ul>   
	    </form>
	</div>
</body>
<script type="text/javascript">
window.onload=function()
{
	var isAddSuccess = '${isAddSuccess}';
	if(isAddSuccess=="success")
	{
		j.omMessageBox.alert({
	           content:'新增角色成功！',
	           onClose:function(v){
	        	   document.location.href = './adminRole.do?action=list';
	           }
	       });
	}
	else if(isAddSuccess=="error")
	{
		j.omMessageBox.alert({
	           content:'新增角色失败！',
	           onClose:function(v){
	           }
	       });
	}
};
</script>
</html>